import request from "@/utils/request";
import type { AxiosPromise } from "axios";
import type {
  VideoVO,
  VideoForm,
  VideoQuery,
  VideoData,
} from "@/api/video/types";

/**
 * 查询视频基础信息列表
 * @param query
 * @returns {*}
 */

export const listVideo = (query?: VideoQuery): AxiosPromise<VideoVO[]> => {
  return request({
    url: "/business/video/list",
    method: "get",
    params: query,
  });
};

/**
 * 查询视频基础信息列表 -> 我的
 * @param query
 * @returns {*}
 */
export const listVideoByMy = (query?: VideoQuery): AxiosPromise<VideoVO[]> => {
  return request({
    url: "/business/video/listByMy",
    method: "get",
    params: query,
  });
};

/**
 * 查询视频基础信息详细
 * @param id
 */
export const getVideo = (id: string | number): AxiosPromise<VideoVO> => {
  return request({
    url: "/business/video/" + id,
    method: "get",
  });
};

/**
 * 新增视频基础信息
 * @param data
 */
export const addVideo = (data: VideoForm[]) => {
  return request({
    url: "/business/video",
    method: "post",
    data: data,
  });
};

/**
 * 修改视频基础信息
 * @param data
 */
export const updateVideo = (data: VideoForm) => {
  return request({
    url: "/business/video",
    method: "put",
    data: data,
  });
};

/**
 * 删除视频基础信息
 * @param id
 */
export const delVideo = (id: string | number | Array<string | number>) => {
  return request({
    url: "/business/video/" + id,
    method: "delete",
  });
};

/**
 * 视频数据
 * @param id
 */
export const videoData = (): AxiosPromise<VideoData> => {
  return request({
    url: "/business/video/videoData",
    method: "get",
  });
};

/**
 * 交互操作
 */
export const interactiveOperateApi = (data: any) => {
  return request({
    url: "/business/video/interactiveOperate",
    method: "post",
    data: data,
  });
};

/**
 * 最近点赞和投币视频-一个月内各自最新10条
 */
export const getRecentLikeVideos = (userId: number | string) => {
  return request({
    url: `/business/video/getRecentLikeVideos/${userId}`,
    method: "get",
  });
};
